<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:t="http://xmlns.jcp.org/jsf/passthrough">
    <h:head>
        <h:outputStylesheet library="css" name="default.css" />
    </h:head>
    <h:body>
        <h:form>
            <p:panelGrid columns="2" styleClass="userPanel">


                <p:commandButton value="userData" icon="ui-icon-pencil" rendered="#{facesContext.externalContext.isUserInRole('admin')}"/>
                <p:commandButton action="users" value="Register"/>
                <p:commandButton value="logout" actionListener="#{controller.logout}" icon="ui-icon-arrowreturnthick-1-w" rendered="#{facesContext.externalContext.authType!=null}"/>
                <p:commandButton value="login" action="login" icon="ui-icon-arrowreturnthick-1-w" rendered="#{facesContext.externalContext.authType==null}"/>
            </p:panelGrid>
        </h:form>
        <h:form id="myForm">

            <p:growl id="growl" showDetail="true" sticky="true" /> 

            <p:panelGrid columns="3" style="left: 40%; position: absolute ; top: 40%;" id="panel" t:draggable="true">

                <f:facet name="header">mail data</f:facet>

                <h:outputLabel for="Recipnt" value="Recipnt" />
                <p:inputText id="Recipnt" value="#{sender.recipnt}" label="Recipnt" required="true" requiredMessage="This field is required"/>
                <p:message for="Recipnt"/>
                <h:outputLabel for="subject" value="Subject" />
                <p:inputText id="subject" value="#{sender.subject}" 
                             label="subject"/>
                <p:message for="subject"/>
                <h:outputLabel for="content" value="Content" />
                <p:inputTextarea id="content" value="#{sender.content}" 
                                 label="content"/>
                <p:message for="content"/>
                <h:outputText id="result" value="#{sender.output}"/>
                <f:facet name="footer">

                    <p:commandButton value="Send" icon="ui-icon-check" actionListener="#{sender.sendMail}" update="myForm" id="sender">

                    </p:commandButton>
                    <p:dialog id="basicDialog" header="Status" widgetVar="dlg1" visible="#{sender.done}" >  
                        <h:outputText value="email done!" />  
                    </p:dialog> 
                </f:facet>

            </p:panelGrid>
            <p:blockUI block="panel" trigger="sender" >  
                LOADING<br />  
                <p:graphicImage library="images" name="loading.gif" width="50" height="50"/>   
            </p:blockUI> 

        </h:form>
        <br />
        <h:form>
            <p:commandButton  icon="ui-icon-check" action="navigations/welcomePrimefaces" value="navugate"></p:commandButton>
        </h:form>
        <h:link outcome="users/users" value="Primefaces welcome page" />

    </h:body>

</html>

